Quadmesh

Download this notebook from GitHub (right-click to download).


In [1]:
import hvplot.xarray  # noqa
In [2]:
import xarray as xr

ds = xr.tutorial.open_dataset('rasm')
ds
Out[2]:
Show/Hide data repr Show/Hide attributes
xarray.Dataset
    • time: 36
    • x: 275
    • y: 205
    • time
      (time)
      object
      1980-09-16 12:00:00 ... 1983-08-17 00:00:00
      long_name :
      time
      type_preferred :
      int
      array([cftime.DatetimeNoLeap(1980-09-16 12:00:00),
             cftime.DatetimeNoLeap(1980-10-17 00:00:00),
             cftime.DatetimeNoLeap(1980-11-16 12:00:00),
             cftime.DatetimeNoLeap(1980-12-17 00:00:00),
             cftime.DatetimeNoLeap(1981-01-17 00:00:00),
             cftime.DatetimeNoLeap(1981-02-15 12:00:00),
             cftime.DatetimeNoLeap(1981-03-17 00:00:00),
             cftime.DatetimeNoLeap(1981-04-16 12:00:00),
             cftime.DatetimeNoLeap(1981-05-17 00:00:00),
             cftime.DatetimeNoLeap(1981-06-16 12:00:00),
             cftime.DatetimeNoLeap(1981-07-17 00:00:00),
             cftime.DatetimeNoLeap(1981-08-17 00:00:00),
             cftime.DatetimeNoLeap(1981-09-16 12:00:00),
             cftime.DatetimeNoLeap(1981-10-17 00:00:00),
             cftime.DatetimeNoLeap(1981-11-16 12:00:00),
             cftime.DatetimeNoLeap(1981-12-17 00:00:00),
             cftime.DatetimeNoLeap(1982-01-17 00:00:00),
             cftime.DatetimeNoLeap(1982-02-15 12:00:00),
             cftime.DatetimeNoLeap(1982-03-17 00:00:00),
             cftime.DatetimeNoLeap(1982-04-16 12:00:00),
             cftime.DatetimeNoLeap(1982-05-17 00:00:00),
             cftime.DatetimeNoLeap(1982-06-16 12:00:00),
             cftime.DatetimeNoLeap(1982-07-17 00:00:00),
             cftime.DatetimeNoLeap(1982-08-17 00:00:00),
             cftime.DatetimeNoLeap(1982-09-16 12:00:00),
             cftime.DatetimeNoLeap(1982-10-17 00:00:00),
             cftime.DatetimeNoLeap(1982-11-16 12:00:00),
             cftime.DatetimeNoLeap(1982-12-17 00:00:00),
             cftime.DatetimeNoLeap(1983-01-17 00:00:00),
             cftime.DatetimeNoLeap(1983-02-15 12:00:00),
             cftime.DatetimeNoLeap(1983-03-17 00:00:00),
             cftime.DatetimeNoLeap(1983-04-16 12:00:00),
             cftime.DatetimeNoLeap(1983-05-17 00:00:00),
             cftime.DatetimeNoLeap(1983-06-16 12:00:00),
             cftime.DatetimeNoLeap(1983-07-17 00:00:00),
             cftime.DatetimeNoLeap(1983-08-17 00:00:00)], dtype=object)
    • xc
      (y, x)
      float64
      ...
      long_name :
      longitude of grid cell center
      units :
      degrees_east
      bounds :
      xv
      array([[189.222932, 189.389909, 189.558366, ..., 293.779061, 294.027924,
              294.274399],
             [188.96837 , 189.134706, 189.302537, ..., 294.05584 , 294.304444,
              294.55066 ],
             [188.712343, 188.878007, 189.045152, ..., 294.335053, 294.583375,
              294.829293],
             ...,
             [124.04724 , 123.88362 , 123.71852 , ...,  16.831718,  16.58437 ,
               16.339496],
             [123.786864, 123.622542, 123.456725, ...,  17.118145,  16.870437,
               16.625183],
             [123.527984, 123.36296 , 123.196441, ...,  17.402099,  17.154053,
               16.908451]])
    • yc
      (y, x)
      float64
      ...
      long_name :
      latitude of grid cell center
      units :
      degrees_north
      bounds :
      yv
      array([[16.534986, 16.778456, 17.022224, ..., 27.363016, 27.11811 , 26.87289 ],
             [16.693973, 16.938654, 17.183645, ..., 27.584772, 27.338218, 27.091366],
             [16.852192, 17.098089, 17.344309, ..., 27.805843, 27.557646, 27.309156],
             ...,
             [17.31179 , 17.561247, 17.811046, ..., 28.450248, 28.197183, 27.943847],
             [17.155897, 17.40414 , 17.652723, ..., 28.231296, 27.979893, 27.728216],
             [16.999195, 17.246229, 17.493587, ..., 28.0116  , 27.761856, 27.511827]])
    • Tair
      (time, y, x)
      float64
      ...
      units :
      C
      long_name :
      Surface air temperature
      type_preferred :
      double
      time_rep :
      instantaneous
      [2029500 values with dtype=float64]
  • title :
    /workspace/jhamman/processed/R1002RBRxaaa01a/lnd/temp/R1002RBRxaaa01a.vic.ha.1979-09-01.nc
    institution :
    U.W.
    source :
    RACM R1002RBRxaaa01a
    output_frequency :
    daily
    output_mode :
    averaged
    convention :
    CF-1.4
    references :
    Based on the initial model of Liang et al., 1994, JGR, 99, 14,415- 14,429.
    comment :
    Output from the Variable Infiltration Capacity (VIC) model.
    nco_openmp_thread_number :
    1
    NCO :
    "4.6.0"
    history :
    Tue Dec 27 14:15:22 2016: ncatted -a dimensions,,d,, rasm.nc rasm.nc Tue Dec 27 13:38:40 2016: ncks -3 rasm.nc rasm.nc history deleted for brevity

quadmesh can be slower that image, but it allows you to plot values on an irregular grid by representing each value as a polygon.

In [3]:
ds.Tair.hvplot.quadmesh(x='xc', y='yc', geo=True, widget_location='bottom')
Out[3]:

To reduce the render time or the size of the saved plot, use rasterize to aggregate the values to the pixel. It is recommended that when rasterizing geo plots, you project before rasterizing, by setting project=True.

In [4]:
ds.Tair.hvplot.quadmesh(x='xc', y='yc', geo=True, widget_location='bottom', rasterize=True, project=True)
Out[4]:

Download this notebook from GitHub (right-click to download).